.\" Copyright (c) 1994, Oracle and/or its affiliates. All rights reserved.
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
.\" copy of this software and associated documentation files (the "Software"),
.\" to deal in the Software without restriction, including without limitation
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
.\" and/or sell copies of the Software, and to permit persons to whom the
.\" Software is furnished to do so, subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice (including the next
.\" paragraph) shall be included in all copies or substantial portions of the
.\" Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
.\" THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
.\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
.\" DEALINGS IN THE SOFTWARE.
.TH rasterfile 5 "29 March 1994"
.IX "images" "ras" "images" "rasterfile image format \(em \f3rasterfile\f1(5)"
.IX "rasterfile" "" "\f3rasterfile\f1(5) \(em raster image format file " ""
.SH NAME
rasterfile \- Sun's file format for raster images
.SH SYNOPSIS
.B #include <pixrect/rasterfile.h>
.SH DESCRIPTION
.LP
A rasterfile is composed of three parts:
first, a header containing 8 integers;
second, a (possibly empty) set of colormap values;
and third, the pixel image, stored a line at
a time, in increasing
.I y
order.  The image is layed out in the file
as in a memory pixrect.  Each line of the
image is rounded up to the nearest 16 bits.
.IX "rasterfile"
.LP
The header is defined by the following structure:
.LP
.RS
.nf
struct rasterfile {
	int	ras_magic;
	int	ras_width;
	int	ras_height;
	int	ras_depth;
	int	ras_length;
	int	ras_type;
	int	ras_maptype;
	int	ras_maplength;
};
.fi
.ft R
.RE
.LP
The
.I ras_magic
field always contains the following constant:
.IP
.B #define	\s-1RAS_MAGIC\s0	0x59a66a95
.LP
The
.IR ras_width ,
.IR ras_height ,
and
.I ras_depth
fields contain the image's width and height in pixels,
and its depth in bits per pixel, respectively.
The depth is either 1 or 8, corresponding
to standard frame buffer depths.  The
.I ras_length
field contains the length in bytes of the image data.
For an unencoded image, this number is
computable from the
.IR ras_width ,
.IR ras_height ,
and
.I ras_depth
fields, but for an encoded image it must be explicitly stored in
order to be available without decoding the image itself.
Note: the length of the header and of
the (possibly empty)
colormap values are not included in the value of the
.I ras_length
field; it is only the image data length.
For historical reasons, files of type
.SM RT_OLD
will usually have a 0 in the
.I ras_length
field, and software expecting to encounter such files
should be prepared to compute the actual
image data length if needed.  The
.I ras_maptype
and
.I ras_maplength
fields contain the type and length in
bytes of the colormap values, respectively.  If
.I ras_maptype
is not
.SM RMT_NONE
and the
.I ras_maplength
is not 0, then the colormap values are the
.I ras_maplength
bytes immediately after the header.
These values are either uninterpreted
bytes (usually with the
.I ras_maptype
set to
.SM RMT_RAW\s0)
or the equal length red, green and blue
vectors, in that order (when the
.I ras_maptype
is
.SM RMT_EQUAL_RGB\s0).
In the latter case, the
.I ras_maplength
must be three times the size in bytes
of any one of the vectors.
